//
//  PSTreeLevelTests.m
//  PrefCore
//
//  Created by Sergey on 5/15/14.
//  Copyright (c) 2014 Play-on-smart. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "PSTreeLevel.h"
#import "PSNode.h"

@interface PSTreeLevelTests : XCTestCase

@end

@implementation PSTreeLevelTests

- (void)testCreate {
    PSTreeLevel *lvl = [[PSTreeLevel alloc] initWithRound:321];
    XCTAssertEqual(321, lvl.round);
    XCTAssertEqual(0, lvl.pending.count);
    XCTAssertEqual(0, lvl.processed.count);
    XCTAssertEqual(0, lvl.complete.count);
}

typedef enum {
    kPending, kProcessed, kComplete
} ListName;

-(void)testClearExceptPending {
    PSTreeLevel *lvl = [[PSTreeLevel alloc] initWithRound:1];
    PSNode *n0 = [PSNode nodeWithLevel:lvl starter:0 hand0:1 hand1:2 hand2:4];
    PSHandHash hands[] = {8, 16, 32};
    PSNode *n1 = [PSNode nodeWithLevel:lvl
        parent:n0
        hands:hands
        player:0
        winner:0
        card0:[PSCard cardWithIndex:10]
        card1:[PSCard cardWithIndex:11]
        card2:[PSCard cardWithIndex:12]
    ];
    XCTAssertEqual(2, lvl.pending.count);
    [lvl clearExcept:n1];
    XCTAssertEqual(1, lvl.pending.count);
}

@end
